var addVue = new Vue({
	el: "#app",
	data: {
		flag: true,
		title: "新增地址",
		area: "",
		name: "",
		tel: "",
		address: ""
	},
	methods: {
		save: function() {
			if (this.name.trim() == "") {
				return wx.showToast({
					title: "收货人不能为空",
					icon: "none",
					duration: 1e3,
					mask: !0
				})
			}
			if (this.tel.trim() == "") {
				return wx.showToast({
					title: "联系电话不能为空",
					icon: "none",
					duration: 1e3,
					mask: !0
				})
			}
			if (this.tel.length != 11) {
				return wx.showToast({
					title: "电话号码格式不正确!",
					icon: "none",
					duration: 1e3,
					mask: !0
				})
			}
			if (this.area.length < 0) {
				return wx.showToast({
					title: "请选择所在地区!",
					icon: "none",
					duration: 1e3,
					mask: !0
				})
			}
			if (this.address.length < 0) {
				return wx.showToast({
					title: "具体地址不能为空!",
					icon: "none",
					duration: 1e3,
					mask: !0
				})
			}
			wx.showLoading({
				title: "提交中...",
				mask: !0
			});
			this.$http.post(baseUrl + "address/save", {
				name: this.name,
				tel: this.tel,
				area: this.area,
				address: this.address,
				default: this.flag
			}).then(function(e) {
				wx.hideLoading();
				var t = e.data;
				t.success ? (wx.showToast({
					title: "地址添加成功",
					icon: "success",
					duration: 2e3,
					mask: !0,
				}), setTimeout(function(){
					Jump.back();
				},1000))  : wx.showToast({
					title: t.description,
					icon: "none",
					duration: 2e3,
					mask: !1
				});
			}).catch(function(e) {
				console.log(e), wx.hideLoading(), wx.showToast({
					title: "网络错误，请稍后重试",
					icon: "none",
					duration: 2e3,
					mask: !1
				});
			});
		},

	},
	created: function() {
		var type = URLParam.get("type");
		this.title = type=="add"?"新增地址":"编辑地址";
		this.name = URLParam.get("name")?URLParam.get("name"):"";
		this.tel = URLParam.get("tel")?URLParam.get("tel"):"";
		this.area = URLParam.get("area")?URLParam.get("area"):"";
		this.address = URLParam.get("address")?URLParam.get("address"):""; 
		this.flag = URLParam.get("default")?URLParam.get("default")=="true":false;
	}
});
